package com.quotes.ui;

import javax.swing.table.AbstractTableModel;
import com.quotes.datamodell.Symbol;
import com.quotes.datamodell.SymbolList;

public class SymbolsTableModel extends AbstractTableModel
{
	private static final long serialVersionUID = 1L;
	private SymbolList symbols = null;
	
	public SymbolsTableModel(SymbolList symbols) {
		this.symbols = symbols;
	}
	
	@Override
	public int getRowCount() {
		return symbols.getSymbols().size();
	}

	@Override
	public int getColumnCount() {
		return 3;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Symbol symbol = symbols.getSymbols().get(rowIndex);
		
		switch (columnIndex) {
			case 0: return symbol.getId(); 
			case 1: return symbol.getYahooName();
			case 2: return symbol.getFullName();
		}
		
		return "";
	}
	
	@Override
	public String getColumnName(int columnIndex) {
		switch (columnIndex) {
			case 0: return "Id"; 
			case 1: return "YahooName";
			case 2: return "FullName";
		}
	
		return "";
	}
}
